package cn.jobstart.es.service;

import cn.jobstart.es.listener.event.EsEvent;
import cn.jobstart.es.model.AbstractEsModel;
import cn.jobstart.pubInter.exception.SkException;
import org.dromara.easyes.core.biz.EsPageInfo;
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
import org.dromara.easyes.core.core.BaseEsMapper;

import java.util.List;

/**
 * @author sunke
 * @version 1.0
 * @Description
 * @date 2023-09-22 11:16
 */
public interface IEsService<E extends AbstractEsModel, ESearch extends LambdaEsQueryWrapper<E>, EM extends BaseEsMapper<E>, EV extends EsEvent> {


    /**
     * 创建索引
     * @return
     * @throws SkException
     */
    boolean createIndex() throws SkException;

    /**
     * 删除索引
     * @return
     * @throws SkException
     */
    boolean deleteIndex() throws SkException;


    /**
     * 异步发消息
     * @param event
     * @throws SkException
     */
    void publishEvent(EsEvent event) throws SkException;


    /**
     * 根据动态查询条件，查询全部记录
     * @param search
     * @return
     * @throws SkException
     */
    List<E> selectList(ESearch search) throws SkException;

    /**
     * 详情
     *
     * @param id
     * @return
     * @throws SkException
     */
    E detailById(String id) throws SkException;


    /**
     * 添加
     *
     * @param domain
     * @return
     * @throws SkException
     */
    E insert(E domain) throws SkException;

    /**
     * 更新
     *
     * @param domain
     * @return
     * @throws SkException
     */
    E update(E domain,String id) throws SkException;

    /**
     * 删除
     *
     * @param id
     * @return
     * @throws SkException
     */
    int delete(String id) throws SkException;

    /**
     * 查询
     *
     * @param eSearch
     * @param pageNum
     * @param pageSize
     * @return
     * @throws SkException
     */
    EsPageInfo<E> pageQuery(ESearch eSearch, int pageNum, int pageSize) throws SkException;

    /**
     *  查询条数
     * @param eSearch
     * @return
     * @throws SkException
     */
    long getCountBySearch(ESearch eSearch)  throws SkException;
}
